import * as echarts from '../../ec-canvas/echarts';

const app = getApp();

function initChart(canvas, width, height) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height
  });
  canvas.setChart(chart);

  var option = {
    backgroundColor: "#ffffff",
    color: ["#37A2DA"],
    tooltip: {},
    xAxis: {
      show: false
    },
    yAxis: {
      show: false
    },
    radar: {
      // shape: 'circle',
      indicator: [{
        name: '拥有房屋数量',
        max: 5
      },
      {
        name: '目标金额',
        max:5000000
      },
      {
        name: '预约次数',
        max: 3
      },
      {
        name: '购房次数',
        max: 5
      },
      {
        name: '年收入',
        max: 500000
      },
      {
        name: '想要户型',
        max: 500
      }
      ]
    },
    series: [{
      name: '客户数据',
      type: 'radar',
      data: [{
        value: [4, 5000000, 2, 4, 470000, 490],
        name: '客户'
      }
      ]
    }]
  };

  chart.setOption(option);
  return chart;
}

Page({
  onShareAppMessage: function (res) {
    return {
      title: 'ECharts 可以在微信小程序中使用啦！',
      path: '/pages/index/index',
      success: function () { },
      fail: function () { }
    }
  },
  data: {
    ec: {
      onInit: initChart
    }
  },

  onReady() {
  }
});
